package com.yincai.carefreewater.tool;

import com.yincai.carefreewater.constant.URLConstant;
import com.yincai.carefreewater.video.Config;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${zk} on 2018\1\24 0024.
 *
 * 操作SD卡
 */

public class SdcardTool {

    /**
     * 从 Sd卡 获取数据
     */
    public static  List<String>    findVideoFromSDK(){
        File file =new File(Config.DEFAULT_CACHE_DIR);
        List<String> list_video=new ArrayList<>();
        if(file.exists()){
            String[] list = file.list();
            for (int i = 0; i <list.length ; i++) {
                String s = list[i];
                if(s.endsWith(".mp4")){
                    int last = s.lastIndexOf(".");
                    int frist = s.lastIndexOf("-")+1;
                    String substring = s.substring(frist, last);
                    list_video.add(URLConstant.HOST+s);
                }
            }
        }
        return list_video;

    }
}
